package com.itheima.model.vo;

import com.itheima.model.mongo.Voice;
import com.itheima.model.pojo.UserInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class VoiceVo {

    private Long id;   // 用户id
    private String avatar; // 头像
    private String nickname; // 名称
    private String gender; // 性别
    private Integer age; // 年龄

    private String soundUrl; // 语音地址

    private Integer remainingTimes; // 剩余次数

    public static VoiceVo init(UserInfo userInfo, Voice voice, Integer remainingTimes) {
        VoiceVo voiceVo = new VoiceVo();
        BeanUtils.copyProperties(userInfo, voiceVo);

        voiceVo.setSoundUrl(voice.getVoiceUrl());
        voiceVo.setRemainingTimes(remainingTimes);


        return voiceVo;
    }

}
